package com.meter.data.controller;

import java.util.List;

import com.meter.common.utils.ShiroUtils;
import com.meter.common.utils.poi.ExcelUtil;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.meter.common.annotation.Log;
import com.meter.common.enums.BusinessType;
import com.meter.data.domain.AlarmData;
import com.meter.data.service.IAlarmDataService;
import com.meter.common.core.controller.BaseController;
import com.meter.common.core.domain.AjaxResult;
import com.meter.common.core.page.TableDataInfo;

/**
 * 告警记录Controller
 * 
 * @author ruoyi
 * @date 2025-05-15
 */
@Controller
@RequestMapping("/data/alarm")
public class AlarmDataController extends BaseController
{
    private String prefix = "data/alarm";

    @Autowired
    private IAlarmDataService alarmDataService;

    @RequiresPermissions("data:alarm:view")
    @GetMapping()
    public String alarm()
    {
        return prefix + "/alarm";
    }

    /**
     * 查询告警记录列表
     */
    @RequiresPermissions("data:alarm:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(AlarmData alarmData)
    {
        List<AlarmData> list = alarmDataService.selectAlarmDataList(alarmData);
        return getDataTable(list);
    }

    /**
     * 导出告警记录列表
     */
    @RequiresPermissions("data:alarm:export")
    @Log(title = "告警记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AlarmData alarmData)
    {
        List<AlarmData> list = alarmDataService.selectAlarmDataList(alarmData);
        ExcelUtil<AlarmData> util = new ExcelUtil<AlarmData>(AlarmData.class);
        return util.exportExcel(list, "告警记录数据");
    }
}
